package springinpractice.ch2.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/*
 * @author	Willie Wheeler John Wheeler and Zeeshan Maqbool
 * Book		'Spring In Practice' [Book written by Willie Wheeler and John Wheeler]
 * 
 */

@Entity
@Table(name = "emails")
public class Email
{
	private int email_id;
	private String address;
	private String addressType;
	private Employee employee;

	public Email() 
	{
	}
	
	public Email(String address, String addressType) {
	this.address = address;
	this.addressType = addressType;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getEmail_id()
	{
		return email_id;
	}

	public void setEmail_id(int emailId)
	{
		email_id = emailId;
	}

	public String getAddress() {
	return address;
	}
	public void setAddress(String address) {
	this.address = address;
	}
	@Column(name = "address_type")
	public String getAddressType() {
	return addressType;
	}
	public void setAddressType(String addressType) {
	this.addressType = addressType;
	}
	
	@ManyToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="employee_id")
	public Employee getEmployee()
	{
		return employee;
	}

	public void setEmployee(Employee employee)
	{
		this.employee = employee;
	}
}
